/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import entities.*;
import java.sql.*;

/**
 *
 * @author lion
 */
public class AdminDao {

    private Connection conn = null;
    private Statement stm = null;
    private ResultSet rs = null;
    private PreparedStatement ps = null;
    MysqlHelper mysql = new MysqlHelper();

    public int getAdminId(int memberid) throws Exception {
        int id = 0;
        try {
            conn = mysql.GetConnection();
            ps = conn.prepareStatement("SELECT * FROM fl_admin WHERE memberid=?");
            ps.setInt(1, memberid);
            rs = ps.executeQuery();
            while (rs.next()) {
                id = rs.getInt("adminid");
            }
        } catch (Exception e) {
            throw e;
        }
        return id;
    }

    public int getMemberidByAdminId(int adminid) throws Exception {
        int id = 0;
        try {
            conn = mysql.GetConnection();
            ps = conn.prepareStatement("SELECT * FROM fl_admin WHERE adminid=?");
            ps.setInt(1, adminid);
            rs = ps.executeQuery();
            while (rs.next()) {
                id = rs.getInt("memberid");
            }
        } catch (Exception e) {
            throw e;
        }
        return id;
    }
}
